import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 登录路由
  { name:'login', path:'/login', component: ()=>import('@/views/login') },
  // 主体框架
  { 
    // 如果父级路由指定到某个子集路由那么，可以不用写name
    // name:'layout', 
    path:'/', 
    component: ()=>import('@/views/layout'),
    children:[
      { name:'home', path:'/', component: ()=> import('@/views/home') },
      { name:'wd', path:'/wd', component: ()=> import('@/views/wd') },
      { name:'video', path:'/video', component: ()=> import('@/views/video') },
      { name:'user', path:'/user', component: ()=> import('@/views/user') },
    ] 
  },
  // 搜索页面路由
  { name:'search', path:'/search', component: ()=>import('@/views/search') },
  { name:'article', path:'/article/:articleId', component: ()=>import('@/views/article'),
  //将路由动态参数映射到组件的 props 中，更推荐这种做法
  props:true
  },
  ]

const router = new VueRouter({
  routes
})

export default router
